/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.insurance.cis.models;

import com.insurance.cis.utils.CisConstants;
import com.insurance.cis.utils.Utils;
import java.text.DecimalFormat;
import java.util.Date;

/**
 *
 * @author TruongLQ
 */
public class Campaign {
    String campaignID, campaignName;
    Product product;
    Channel channel;
    Promotion promotion;
    double estimatedBudget, estimatedSale, actualBudget, actualSale;
    Date startDate, endDate;
    
    public Campaign(){
        
    }
    public Campaign(String campaignID, String campaignName, double estimatedBudget, 
            double estimatedSale, double actualBudget, double actualSale, 
            Date startDate, Date endDate) {
        this.campaignID = campaignID;
        this.campaignName = campaignName;
        this.estimatedBudget = estimatedBudget;
        this.estimatedSale = estimatedSale;
        this.actualBudget = actualBudget;
        this.actualSale = actualSale;
        this.startDate = startDate;
        this.endDate = endDate;
    }

    
    public void setCampaignID(String campaignID) {
        this.campaignID = campaignID;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public void setPromotion(Promotion promotion) {
        this.promotion = promotion;
    }
    public void setEstimatedBudget(double estimatedBudget) {
        this.estimatedBudget = estimatedBudget;
    }
    public void setEstimatedSales(double estimatedSales) {
        this.estimatedSale = estimatedSales;
    }
    
    public String getStartDateStr() {
        if (startDate!=null) {
            return Utils.convertDateToString(startDate, CisConstants.DATE_DD_MM_YYYY);
        }
        return CisConstants.BLANK;
    }
    
    public String getEndDateStr() {
        if (endDate!=null) {
            return Utils.convertDateToString(endDate,CisConstants.DATE_DD_MM_YYYY);
        }
        return CisConstants.BLANK;
    }

    public String getCampaignID() {
        return campaignID;
    }

    public String getCampaignName() {
        return campaignName;
    }

    public Product getProduct() {
        return product;
    }

    public Channel getChannel() {
        return channel;
    }

    public Promotion getPromotion() {
        return promotion;
    }

    public double getEstimatedBudget() {
        return estimatedBudget;
    }

    public double getEstimatedSale() {
        return estimatedSale;
    }

    public double getActualBudget() {
        return actualBudget;
    }

    public double getActualSale() {
        return actualSale;
    }

    public Date getStartDate() {
        return startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public String getBudgetVariance() {
        if (estimatedBudget!=0) {
            final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
            return DECIMAL_FORMAT.format((actualBudget-estimatedBudget)/estimatedBudget);
        }
        return "";
    }
    
    public String getSaleVariance() {
        if (estimatedSale!=0) {
            final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
            return DECIMAL_FORMAT.format((actualSale-estimatedSale)/estimatedSale);
        }
        return "";
    }
    
}
